<script src="<?php print $url?>js/jquery.ui.datepicker.js"></script>
<div id="main-content">
  <div class="container-fluid">
    <div class="row-fluid">
			<div class="span12">
				<div class="widget-block">
					<div class="widget-head">
						<h5><?php print $title?></h5>
            <div class="widget-control pull-right">
              <a href="#" data-toggle="dropdown" class="btn dropdown-toggle"><i class="icon-cog"></i><b class="caret"></b></a>
              <ul class="dropdown-menu">
                <li><a href="<?php print   site_url("keuangan-mahasiswa/keuangan-mahasiswa-report/prokul-penerima-beasiswa/") ?>"><i class="icon-plus"></i>Add New</a></li>
              </ul>
            </div>
					</div>
					<div class="widget-content">
            <div class="widget-searchbox">
              <?php print $this->form_eksternal->form_open()?>
              <ul>
                <li class="row-counts">
                  <div class="input-prepend"> <span class="add-on">Prodi-Program Kuliah</span>
                    <?php print $this->form_eksternal->form_dropdown("cari_prokul", $prokul_drop, array($prokul_pilih), "id='prokul_drop'");?>
                  </div>
                </li>
                <li class="row-counts">
                  <div class="input-prepend"> <span class="add-on">Semester/Tahun Ajaran</span>
                    <span id='sta_pilih'><?php print $this->form_eksternal->form_dropdown("cari_sta", $sta_drop, array($sta_pilih));?></span>
                  </div>
                </li>
              </ul>
              <ul>
                <li class="row-counts">
                  <div class="input-prepend"> <span class="add-on">Angkatan</span>
                    <?php print $this->form_eksternal->form_dropdown("cari_kelompok", $kelompok_drop, array($kelompok_pilih));?>
                  </div>
                </li>
              </ul>
              <ul>
                <li class="row-counts">
                  <button type="submit" name="cari" value="cari" class="btn btn-small">Search</button>
                </li>
              </ul>
              </form>
              <br />
            </div>
            <div class="widget-box">
              <table id="inti-quotation" class="table table-striped">
                <thead>
                  <tr>
                    <th><?php print lang("zikula_nim")?></th>
                    <th><?php print lang("name")?></th>
                    <th>Kelompok</th>
                    <th>Semester Tahun Ajaran</th>
                    <th>Penerimaan</th>
                    <th>Action</th>
                  </tr>
                </thead>
                <tbody id="ajax-body-quotation">
                  <?php
                  $no = 1;
                  foreach($data AS $dt){
                    $this->global_models->get_connect("zikula");
                    $mahasiswa = $this->global_models->get_query("
                      SELECT A.nama, C.name AS prodi, B.nama_program AS prokul, D.nama_kelompok
                      FROM academicportal_mahasiswa AS A
                      LEFT JOIN academicportal_program_kuliah AS B ON A.program_kuliah = B.id_program_kuliah
                      LEFT JOIN academicportal_course_categories AS C ON B.category = C.id
                      LEFT JOIN academicportal_kelompok_mahasiswa AS D ON A.kelompok_mahasiswa = D.id_kelompok_mahasiswa
                      WHERE A.nim = '{$dt->nim}'
                      ");
                      
                    $semester_view = $this->global_models->get_field("academicportal_semester", "semester_name", array("id" => $dt->id_semester));
                    
                    $this->global_models->get_connect("default");
                    
                  ?>
                  <tr>
                    <td><?php print $dt->nim;?></td>
                    <td><?php print $mahasiswa[0]->nama;?></td>
                    <td><?php print $mahasiswa[0]->nama_kelompok;?></td>
                    <td><?php print $semester_view." - ".$dt->tahun."/".($dt->tahun+1);?></td>
                    <td style="text-align: right"><?php print number_format($dt->saldo, 0, ",", ".");?></td>
                    <td>
                      <div class='btn-group'>
                        <button data-toggle='dropdown' class='btn btn-small dropdown-toggle'>Action<span class='caret'></span></button>
                        <ul class='dropdown-menu'>
                          <li><a href='<?php print site_url("keuangan-mahasiswa/keuangan-mahasiswa-report/detail-penerima-beasiswa/".$dt->nim)?>'>Detail</a></li>
                        </ul>
                      </div>
                    </td>
                  </tr>
                  <?php
                  $total += $dt->saldo;
                  }
                  ?>
                </tbody>
                <tfoot style="background-color: #dbdbdb">
                  <tr>
                    <td colspan="4"><b>TOTAL</b></td>
                    <td style="text-align: right"><b><?php print number_format(($total), 0, ",", ".");?></b></td>
                    <td style="text-align: right"></td>
                  </tr>
                </tfoot>
              </table>
              <input type="text" value="create_date" id="field_simpan" style="display: none" />
              <input type="text" value="desc" id="sort_simpan" style="display: none" />
            </div>
          </div>
				</div>
			</div>
		</div>
  </div>
</div>
<script>
  $( document ).ready(function(){
    $("#prokul_drop").change(function(){
      $.post('<?php print site_url("keuangan-mahasiswa/get-dropdown-sta/")?>/'+$("#prokul_drop").val()+'/2',{no:3},function(data){
        $("#sta_pilih").html(data);
      });
    });
  });
</script>